<?php 
namespace app\index\model;
use think\Model;
use think\Session;
use think\Db;
use email\Email;
header("Content-type: text/html; charset=utf-8");
class Index_model extends Model
{
	//发布通知
	public function notice_add()
	{
		$model = Db::table('notice')->order('notice_id desc')->limit(3)->select();
		return $model;
	}

	//最新问题
	public function latest_issues()
	{
		$model = Db::table('problem')->field('problem_id,project_username,problem_type,problem_status,problem_priority,problem_change_time')->order('problem_id desc')->limit(3)->select();
		return $model;
	}

	//总数
	public function total()
	{
		
		$sql = Db::query("select count('id') from problem");
		return $sql;
	}

	//拒绝
	public function refuse_to()
	{
		$unsolved = Db::query("select count('problem_status') from problem WHERE problem_status = 1");
		return $unsolved;
	}

	//关闭
	public function closed()
	{
		$unsolved = Db::query("select count('problem_status') from problem WHERE problem_status = 2");
		return $unsolved;
	}

	//已延期
	public function delayed()
	{
		$unsolved = Db::query("select count('problem_status') from problem WHERE problem_status = 3");
		return $unsolved;
	}
	
	//未解决
	public function unsolved()
	{
		$unsolved = Db::query("select count('problem_status') from problem WHERE problem_status = 6");
		return $unsolved;
	}

	//已解决
	public function solved()
	{
		$unsolved = Db::query("select count('problem_status') from problem WHERE problem_status = 7");
		return $unsolved;
	}

	//待审核
	public function pending()
	{
		$unsolved = Db::query("select count('problem_status') from problem WHERE problem_status = 9");
		return $unsolved;
	}

	//项目成员
	public function project_member()
	{
		$unsolved = Db::query("select count('id') from user");
		return $unsolved;
	}

	//任务
	public function task()
	{
		$unsolved = Db::query("select count('problem_type') from problem WHERE problem_type = 0");
		return $unsolved;
	}

	//缺陷
	public function defect()
	{
		$unsolved = Db::query("select count('problem_type') from problem WHERE problem_type = 1");
		return $unsolved;
	}

	//需求
	public function demand()
	{
		$unsolved = Db::query("select count('problem_type') from problem WHERE problem_type = 2");
		return $unsolved;
	}
	//急
	public function anxious()
	{
		$unsolved = Db::query("select count('problem_priority') from problem WHERE problem_priority = 0");
		return $unsolved;
	}
	//高
	public function high()
	{
		$unsolved = Db::query("select count('problem_priority') from problem WHERE problem_priority = 1");
		return $unsolved;
	}
	//中
	public function in()
	{
		$unsolved = Db::query("select count('problem_priority') from problem WHERE problem_priority = 2");
		return $unsolved;
	}
	//低
	public function low()
	{
		$unsolved = Db::query("select count('problem_priority') from problem WHERE problem_priority = 3");
		return $unsolved;
	}
}